fn main() {
    println!("Hello, world!");
    let target = vec![1,3];
    let n = 3;
    let ans = Solution::build_array(target, n);
    println!("{:?}", ans);
}

struct Solution;

impl Solution {
    pub fn build_array(target: Vec<i32>, n: i32) -> Vec<String> {
        let mut ans = Vec::new();
        let mut index = 1;
        for i in 0..target.len() {
            let ele = target[i];
            if index == ele {
                index += 1;
                ans.push("Push".to_string());
            } else {
                loop {
                    if index < ele {
                        index += 1;
                        ans.push("Push".to_string());
                        ans.push("Pop".to_string());
                    } else {
                        index += 1;
                        ans.push("Push".to_string());
                        break;
                    }
                }
            }
        }
        ans
    }
}
